home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-21 / qwhite.zip / HEX.TEC < prev    next >
Text File  |  1992-03-09  |  8KB  |  143 lines

  1. ID:HX Hexadecimal Numbers and QEMM
  2. Quarterdeck Technical Note #190
  3. by Vernon Balbert
  4.  
  5. Q:   Why are these numbers mixed up with these letters and what do they mean?
  6.  
  7. A:   These numbers and letters are part of a numbering system that is used by 
  8.      computers.
  9.  
  10.      Computers don't count the way people do.  People use decimal, or base 10 
  11. for counting and we use the numbers 0-9 giving us 10 different symbols for 
  12. counting.  Computers, on the other hand, use binary, a number system that uses 
  13. just zeros and ones.  So, a typical binary number might look like this:
  14.  
  15.                        1001011011010010
  16.  
  17.      Kind of confusing, huh? Well, even to programmers, these numbers are 
  18. confusing.  People just don't work well with binary. Computers do.  Binary 
  19. numbers can be translated to decimal quite easily, but they just aren't neat.  
  20. For instance, if you use an eight digit binary number, you can count up to 
  21. 255.  Well, this has three decimal numbers and multiples of 256 (counting 0) 
  22. is just not very neat or easy.  However, there is a different way of counting 
  23. that is widely used by computer people.  This is called HEXADECIMAL.  
  24. Hexadecimal is base 16.  What this means is that if you were to start counting 
  25. from 0, you would continue up to some single digit that would represent 15.  
  26. And that's where the letters come from.  Hexadecimal numbers go like this:
  27.  
  28.                0 1 2 3 4 5 6 7 8 9 A B C D E F
  29.  
  30.       Well, part of that looks normal, at least until the 9.  The A translates 
  31. as 10, the B as 11 on up until the F is equal to 15. After F, you tack on a 1 
  32. at the beginning of the number just like we do so you would get 10.  And, yes, 
  33. 10 plus 10 equal 20.  Since 10 in hexa- decimal is equal to 16 in decimal, it 
  34. would be logical to assume that if 16+16=32 then 20 hexadecimal equals 32 
  35. decimal.  Rest assured, it does.  Often, to tell the difference between 
  36. hexadecimal and decimal numbers, programmers will use H at the end of the 
  37. number to say that it is hexadecimal, i.e. 10H.  Now, if you have 8 binary 
  38. numbers, you can count either to 256, or to FFH.  (Remember, the H stands for 
  39. hexadecimal.) This means that you can count in multiples of 4 binary digits 
  40. with one hexadecimal digit.  For instance:
  41.  
  42.                  10010110=96H=150 base 10
  43.  
  44.       Now, you might ask, why use multiples of 4 binary digits? Well, the 
  45. answer is really quite simple.  Computer people like to group binary numbers 
  46. in groups of eight.  A hexadecimal number can represent 4 binary digits.  Each 
  47. number is called a bit and each group of eight bits is a byte.  And computer 
  48. memory is measured in bytes.  Each byte can represent one character such as 
  49. the letter "Q" or the number "3".  Your hard disk is measured in megabytes, or 
  50. millions of bytes.  So,  hexadecimal is a number system that both computers 
  51. and humans can work with easily. Actually, computers don't work with 
  52. hexadecimal, but most programs that work with hexadecimal numbers have 
  53. routines that translate the hexadecimal numbers to binary for the computer 
  54. because it's so easy; simply convert each hex digit into the appropriate 4 
  55. binary digits.  By the way, hexadecimal is often referred to as "hex" for 
  56. short.
  57.  
  58.      Okay, now we have to delve a little into the history of IBM PCs to 
  59. understand the way you address memory.
  60.  
  61.      When IBM first came out with the PC, the Intel 8088 processor was used.  
  62. The 8088 can access 1 megabyte of memory. However, the chip only has 16 bit 
  63. registers.  (A register is an internal memory loca- tion.) You can only count 
  64. to 65535 with 16 bits.  In order to access the 20 bits outside the 
  65. microprocessor, an alternate method of ad- dressing memory was developed.  So, 
  66. addresses had the following format:
  67.  
  68.                           ssss:oooo
  69.  
  70.      The first four hex digits (ssss) are the segment address. The last four 
  71. (oooo) are the offset address.  Together, these can address the entire 1 
  72. megabyte space of the 8088.  This is called relative addressing.  You never 
  73. actually say the exact address that you are pointing at, just an address 
  74. relative to a different position.  For instance, if you have an address such 
  75. as 1234:2319, you would take 1234H, add a 0 to the end so it turns into 12340H 
  76. and then add 2319H to it to get 14659H.
  77.  
  78.      When the 80286 came out, it had 24 address lines to address more than the 
  79. 1 megabyte of memory available.  (24 address lines lets you address 16 
  80. megabytes of memory.) Additionally, the internal registers were enlarged to 24 
  81. bits so you didn't have to go through the segment and offset gyrations.  So, 
  82. you could now use absolute addressing.  The address now takes this format:
  83.  
  84.                            XXXXXX
  85.  
  86.      Notice now, that there are 6 digits instead of two sets of 4 when an 
  87. 80286 is in "protected" mode (6 digit mode).  DOS, unfortunately, only 
  88. understands segmented memory addressing which is in "real" mode.  Intel built 
  89. in a "real" mode into the 80286 and higher processors so that they would still 
  90. understand relative addressing.  This difference is VERY important.  It is the 
  91. main reason that you can't use exTENDed memory (only available in "protected" 
  92. mode) to run DOS programs (which require "real" mode).  
  93.  
  94.      QEMM, QRAM and DESQview all observe the relative addressing scheme.  So, 
  95. when you include or exclude areas of memory with QEMM, you use the segment 
  96. address.  Typically, the only exclusions you will use involve the area above 
  97. the 640K program space.  This is a 384K area of memory that is normally used 
  98. by adapter cards and ROMs in your computer.  The address range of the lower 
  99. 640K is 0000-9FFF.  Remem-ber, these are the segment addresses, not the offset 
  100. addresses.  The area above 640K is the A000-FFFF range.
  101.  
  102. Here is a translation table so you can convert some common hexadecimal 
  103. addresses into decimal and back.
  104.  
  105. Common way of    Decimal    Hexadecimal    Segment:Offset 
  106.  saying it
  107.  
  108.     1K             1024         400     0040:0000 or 0000:0400
  109.     2K             2048         800     0080:0000 or 0000:0800
  110.     4K             4096        1000     0100:0000 or 0000:1000
  111.     8K             8192        2000     0200:0000 or 0000:2000
  112.    16K            16384        4000     0400:0000 or 0000:4000
  113.    32K            32768        8000     0800:0000 or 0000:8000
  114.    64K            65536       10000           1000:0000
  115.   128K           131072       20000           2000:0000
  116.   256K           262144       40000           4000:0000
  117.   384K           393612       60000           6000:0000
  118.   512K           524288       80000           8000:0000 
  119.   640K           655350       A0000           A000:0000
  120.   704K           720896       B0000           B000:0000
  121.   736K           753664       B8000           B800:0000
  122.   768K           786432       C0000           C000:0000 
  123.   832K           851968       D0000           D000:0000
  124.   896K           917504       E0000           E000:0000
  125.   960K           983040       F0000           F000:0000
  126.  1024K          1048576      100000      1MB and beyond cannot
  127.                                          be addressed with the    
  128.                                          segment:offset method.
  129.  
  130. In summary, we see that hexadecimal (or hex, for short) is actually base 16, 
  131. decimal is base 10 and binary is base 2.  Hex numbers go from 0 to F, decimal 
  132. numbers go from 0 to 9 and binary go from 0 to 1.  Hex numbers are used to 
  133. make it easier for people to work with numbers that the computer uses.
  134.  
  135.  
  136.   ************************************************************************
  137.   *This technical note may be copied and distributed freely as long as it*
  138.   *is distributed in its entirety and it is not distributed for profit.  *
  139.   *         Copyright (C) 1990-2 by Quarterdeck Office Systems           *
  140.   ************************ E N D   O F   F I L E *************************
  141.  
  142.  
  143.